﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using OpenTK;
using OpenTK.Graphics.OpenGL;

//needs matrix
//orthoganal view

//? GLSL uses Column Major   // OpenTK uses column major as well

namespace Platform359a.Core.Gfx
{
    public enum CameraAxis
    {
        X,
        Y,
        Z,
    }
   
    class Camera
    {
        Matrix4 mCameraMatrix;
        Vector2 mCamZoom;

        public Camera()
        {
            mCameraMatrix = new Matrix4();
            mCamZoom = new Vector2();
        }

        public Camera(int pWidth, int pHeight) : this()
        {
      
            CreateOrthoganlView(pWidth, pHeight);
        }

        public void CreateOrthoganlView(float pWidth, float pHeight)
        {
            mCameraMatrix = Matrix4.CreateOrthographic(pWidth, pHeight, 0, -100);
            mCamZoom = new Vector2(pWidth, pHeight);
        }

        public void Zoom(float pZoomAmount)
        {
            mCamZoom.X -= pZoomAmount;
            mCamZoom.Y -= pZoomAmount;

            CreateOrthoganlView(mCamZoom.X, mCamZoom.Y);
        }

        public float GetZoom()
        {
            return mCamZoom.X;
        }

        public void MoveCamera(float pX, float pY)
        {
            //? create translation only creates a translation matrix, must manually multiply to camera matrix
            mCameraMatrix = Matrix4.Mult(mCameraMatrix, Matrix4.CreateTranslation(pX, pY, 0)); 
        }


        public void SetCamera(float pX, float pY)
        {
            mCameraMatrix = Matrix4.CreateTranslation(pX, pY, 0); 
        }

        public Vector2 GetCoords()
        {
            return new Vector2(mCameraMatrix.Column0.W, mCameraMatrix.Column1.W);
        }


    }
}
